import { coreDispatch } from "../utils/StoreUtil";


// @ts-ignore
const closeModal: Function = async (key: string, fn: Function) => {
    let resultData: any = await fn && fn();
    coreDispatch("modalReducer/closeModal", { key, resultData })
};

// @ts-ignore
const addResultData: Function = async (key: string, resultData: any) => {
    coreDispatch("modalReducer/updateModal", { key, resultData })
}

// @ts-ignore
const addOkModal: Function = (key: string, fn: Function) => {
    coreDispatch("modalReducer/updateModal", { key, onOk: fn })
};

// @ts-ignore
const updataModalFooter: Function = (key: string, footer: any[]) => {
    coreDispatch("modalReducer/updateModal", { key, footer: footer })
}

// @ts-ignore
const updataModalTitle: Function = (key: string, modalProps: any) => {
    coreDispatch("modalReducer/updateModal", { key, modalProps: modalProps})
}


export {
    addOkModal,
    addResultData,
    closeModal,
    updataModalFooter,
    updataModalTitle
}